//
//  myResumeCellEduExper.swift
//  LeDian
//
//  Created by 三秒文化 on 16/3/18.
//  Copyright © 2016年 51ledian. All rights reserved.
//

import UIKit

class myResumeCellEduExper:LDBaseRecFinderCell {

    var eduTitleLab:UILabel?
    var eduImgView:UIImageView?
    var divideLine:UIImageView?
    var rowsview:myResumeCellEduRowsView?
    let rowsViewTag = 666
    
    var model = myResumeCellEduExperModel() {
        
        didSet {
            
            updateFrame()
        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.frame = LDFrame.ScreenBounds
        setDefaultContent()
        setupFrame()
    }
    
    //update
    func updateFrame() {
        
        
        let count:Int = Int(model.eduexperiencecount)!
        for i in 0..<count {
            
            let views = myResumeCellEduRowsView()
            views.model = myResumeCellEduExperModel_edu.yy_modelWithDictionary(model.eduexperience[i])
            views.tag = rowsViewTag + i
            gapView.addSubview(views)
        }
        
        for i in 0..<count {
            let views = viewWithTag(rowsViewTag+i) as! myResumeCellEduRowsView
            
            if i < 1 {

                views.snp_makeConstraints(closure: { (make) in
                    make.top.equalTo((divideLine?.snp_bottom)!).offset(LDMargin_V*3)
                    make.left.equalTo(LDMargin_V*3)
                    make.right.equalTo(-LDMargin_V*3)
                    make.height.equalTo(model.rowheight)
                })
                
            } else {
                
                let preView = viewWithTag(rowsViewTag+i-1) as! myResumeCellEduRowsView
                views.snp_makeConstraints(closure: { (make) in
                    make.top.equalTo(preView.snp_bottom).offset(LDMargin_V)
                    make.left.equalTo(LDMargin_V*3)
                    make.right.equalTo(-LDMargin_V*3)
                    make.height.equalTo(model.rowheight)
                })
            }
        }
    }
    
    func setDefaultContent() {
        
        eduTitleLab = UILabel.setHeadTitleLab("教育经历")
        divideLine = UIImageView.setupDivideLine_H(LDFrame.ScreenWidth - Margin_V*10)
        
        gapView.addSubview(eduTitleLab!)
        gapView.addSubview(divideLine!)
    }
    
    func setupFrame() {
        
        
        eduTitleLab!.anchorInCorner(.TopLeft, xPad: Margin_V*3, yPad: Margin_V*4, width: 200, height: 20)
        divideLine?.align(.UnderMatchingLeft, relativeTo: eduTitleLab!, padding: Margin_V*3, width: LDFrame.ScreenWidth - Margin_V*10, height: 1)

    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }

}
class myResumeCellEduExperModel:NSObject {
    
    var eduInfo:Array<AnyObject>?
    var rowheight:CGFloat = 50 //[CGFloat]()

    lazy var height:CGFloat = {
        var h = (self.rowheight+LDMargin_V*2) * CGFloat(Int(self.eduexperiencecount)!) + LDCellFrame.Margin_V*4 + LDMargin_V*3 + 25 + LDMargin_V*2
        return h
    }()
    
    var eduexperiencecount = "0" //{// 教育经历数目
    var eduexperience = [        // 教育经历数组
        [
            "institutename":"", // 学校名称
            "startdate":"",     // 开始时间
            "enddate":"",       // 结束时间
            "majortitle":"",   // 专业名称
            "edu":""           // 学历
        ]
    ]
    
    
}

class myResumeCellEduExperModel_edu: NSObject {
    
    var institutename = "" // 学校名称
    var startdate = ""     // 开始时间
    var enddate = ""       // 结束时间
    var majortitle = ""   // 专业名称
    var edu = ""           // 学历
    
}
